define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
    console.log(Config);
    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'qikanqishu/index/qikan_id/' + Config.qikan_id,
                    add_url: 'qikanqishu/add',
                    edit_url: 'qikanqishu/edit',
                    del_url: 'qikanqishu/del',
                    multi_url: 'qikanqishu/multi',
                    import_url: 'qikanqishu/import',
                    table: 'qikanqishu',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'weigh',
                search:false,
                searchFormVisible: false,
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'qikan.name', title: __('Qikan_id')},
                        {field: 'year', title: __('Year')},
                        {field: 'qishu', title: __('Qishu'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'shangjia_switch', title: __('Shangjia_switch'), searchList: {"1":__('Yes'),"0":__('No')}, table: table, formatter: Table.api.formatter.toggle},
                        {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'weigh', title: __('Weigh'), operate: false},
                        {field: 'file', title: __('File'), operate: false, formatter: Table.api.formatter.file},
                        {field: 'dir', title: __('Dir'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'qikan.name', title: __('Qikan.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            
            bindevent: function () {
                $("#faupload-file").data("upload-success", function(data){
                      //这里进行后续操作
                      console.log(data);
                      $('#c-dir').val(data.zip_url);
                });
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
